<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="my" uri="/my-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'booksList.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="images/main.css">
	<link rel="stylesheet" type="text/css" href="images/pagingExt.css">
	
	<script type="text/javascript" src="images/jquery.js"></script>
	<script type="text/javascript">
		$(function(){
			function delBook(id){
				//var flag= confirm('确认删除?1');
				if (confirm('确认删除?1'))
				$.ajax({
					type : "post",
					url : "delBook",
					data : {id:id},
					success : function(data){
						alert(data);
						window.location.href="listbook";
					}
				});
			}
			
			$("tr").mouseleave(function(){
				$(this).css("background-color","#fefefe");
				$("thead tr").css("background-color","#F3F8F7");
			});
			$("tr").mouseover(function(){
				$(this).css("background-color","#E9E9E4");
				$("thead tr").css("background-color","#F3F8F7");
			});

		});
	</script>

  </head>
  
  <body>
    <div class="mainBox">
 		<s:set var="datat" value="#{0:'图书',1:'光盘',2:'期刊'}"/>
    	<table class="table_list" cellpadding="3" cellspacing="1" border="0">
    	<thead><tr style="background:#F3F8F7"><td>序号</td><td>条码号/期刊号</td><td>藏馆类型(期刊类型)</td><td>典藏地</td><td>索书号</td><td>题名</td><td>责任人</td><td>出版者</td><td>出版年份/期数</td><td>单价/年价</td><td>ISBN</td><td>在库数量</td><td colspan="3" width="80px">操作</td></tr></thead>

    	<s:iterator value="#session.SESSION_BOOK_LIST" var="each" status="st">
    		<tr style="background:#fefefe">
    		<td><s:property value="#st.index + 1"/></td>
    		<td><s:property value="#each.bookBarCode"/><s:property value="#each.periNo"/></td>
    		<td><s:property value="#datat[#each.dataType]"/>
    		<s:if test="#each.periType!=null">
    		(<s:property value="#each.periType"/>)
    		</s:if>
    		</td>
    		<td><s:property value="#each.bookCollection"/></td>
    		<td><s:property value="#each.bookCallNo"/></td>
    		<td><a href="queryBook?op=info&id=<s:property value="#each.bookId"/>" title="查看本书详情">
    		<s:if test="#each.bookName.length()>=15">
    		<s:property value="#each.bookName.substring(0,14)"/>...
    		</s:if>
    		<s:else>
    		<s:property value="#each.bookName"/>
    		</s:else>
    		</a></td>
    		<td><s:if test="#each.bookChargePerson.length()>=15">
    		<s:property value="#each.bookChargePerson.substring(0,14)"/>...
    		</s:if>
    		<s:else>
    		<s:property value="#each.bookChargePerson"/>
    		</s:else>
			</td>
    		<td><s:property value="#each.bookPublishing"/></td>
    		<td><s:property value="#each.bookPublishingTime"/><s:property value="#each.perPeriods"/></td>
    		<td><s:property value="#each.bookPrice"/></td>
    		<td><a href="http://book.douban.com/isbn/<s:property value="#each.ISBN"/>" target="_blank" title="去豆瓣查看本书介绍"><s:property value="#each.ISBN"/></a></td>
    		<td><s:property value="#each.bookCount"/></td>
    		<td><a href="queryBook?op=detail&id=<s:property value="#each.bookId"/>">修改</a></td>
    		
    		<s:if test="#each.bookCount<1">
    		<td><a href="#" style="color:#ccc">借阅</a></td>
    		</s:if><s:elseif test="#each.bookCount>=1">
    		<td><a onclick="window.open ('borrowBook?bid=<s:property value="#each.bookId"/>&uid=', '请选择借阅用户', 'height=100px, width=600px, scrollbars=no, resizable=no')">借阅</a></td>
    		</s:elseif><s:else>
    		<td> </td>
    		</s:else>
    		
    		<td><a onclick="if (confirm('操作不可恢复，确认删除?'))$.ajax({type:'post',url:'delBook',data:{id:<s:property value="#each.bookId"/>},success : function(data){alert(data);location.reload();}});">删除</a></td>
    		</tr>
    	</s:iterator>
    	
    		<tr style="background:#fefefe"><td colspan="99" align="right">
<my:page pageSize="${sessionScope.SESSION_BOOK_PAGESIZE }" pageNo="${sessionScope.SESSION_BOOK_PAGENO }" url="listBook" count="${sessionScope.SESSION_BOOK_COUNT }"></my:page>
    		</td></tr>
    	</table>
    	
    </div>
  </body>
</html>
